package net.xiangcaowuyu.springcloud.alibaba.seata.service.impl;

import io.seata.core.context.RootContext;
import io.seata.spring.annotation.GlobalTransactional;
import lombok.extern.slf4j.Slf4j;
import net.xiangcaowuyu.springcloud.alibaba.seata.dao.AccountDao;
import net.xiangcaowuyu.springcloud.alibaba.seata.service.IAccountService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.concurrent.TimeUnit;

/**
 * 博客：https://www.xiangcaowuyu.net
 * Description:
 *
 * @Author: 香草物语
 * DateTime: 2021-07-25 21:19
 */
@Service
@Slf4j
public class AccountServiceImpl implements IAccountService {

    @Resource
    private AccountDao accountDao;

    @Override
//    @Transactional
    public int decrease(Long userId, BigDecimal money) {
        log.info("--------->storage-------decrease获取xid：" + RootContext.getXID());
        //默认报错
        int age = 10 / 0;
        return accountDao.decrease(userId, money);
    }
}
